﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class VibratorDemo : MonoBehaviour {
    public Text scalInput;
    public Text msInput;

    public void OnStartVibrator() {
#if UNITY_ANDROID
        int ms = 0;
        if (msInput != null && msInput.text != null) {
            ms = int.Parse(msInput.text);
        }
        VibratorImp.Instance.StartVibrator(ms);
#endif
    }

    public void OnLoopVibrator() {
#if UNITY_ANDROID
        List<long> msArray = new List<long>();
        int ms = 0;
        int scale = 0;
        if (msInput != null && msInput.text != null)
        {
            if(scalInput!=null && scalInput.text != null)
            scale = int.Parse(scalInput.text);
            ms = int.Parse(msInput.text);
        }
        for (int i = 0; i < ms; ) {
            msArray.Add(1);
            msArray.Add(scale);
            i += (10 + scale);
        }
        VibratorImp.Instance.LoopStartVibrator(msArray.ToArray());
#endif
    }

    public void OnStopVibrator() {
#if UNITY_ANDROID
        VibratorImp.Instance.StopVibrator();
#endif
    }
}
